﻿@model IEnumerable<MobileSales.Model.Tasks.CyclicTask>
@using MobileSales.Website.Controllers

@{
    View.Title = Strings.CyclicTasks;
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@Strings.CyclicTasks</h2>

    @using (Html.BeginForm("Index", "CyclicTasks", FormMethod.Get))
    {
    
        @ModelStrings.Employee <text>:</text>
        @Html.EmployeeSelect("employeeId", (int?)ViewData["employeeId"])
        <input type="submit" value="@Strings.Go" />
    }

    <br />


@if (Model != null)
{
<p>
    @Html.ActionLink(Strings.AddTask, "Create", (ViewData["employeeId"] != null) ? new { employeeId = ViewData["employeeId"] } : null, new { @class = "icon-button add-icon" })

    @Html.CyclicTaskCalendar(((int?)ViewData["employeeId"]).Value, Model,
                                          ((DateTime)Session[CyclicTasksController.CyclicTaskDateSessionKey]).Year,
                                           ((DateTime)Session[CyclicTasksController.CyclicTaskDateSessionKey]).Month)
    
    
    
</p>
    <br />

<table class="datatable">
    <thead>
    <tr>
        <th style="width:200px"></th>
        <th>
            @ModelStrings.TaskInterval
        </th>
        <th>
            @ModelStrings.Client
        </th>
        <th>
            @ModelStrings.Info
        </th>
        <th>
            @ModelStrings.Priority
        </th>
        <th>
            @ModelStrings.StartTime
        </th>
        <th>
            @ModelStrings.EndTime
        </th>
    </tr>
    </thead>
    <tbody>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.ActionLink(Strings.Edit, "Edit", new { id = item.Id }, new { @class = "icon-button edit-icon" }) |
            @Html.ActionLink(Strings.Details, "Details", new { id = item.Id }, new { @class = "icon-button details-icon" })<br /><br />
            @Html.ActionLink(Strings.Delete, "Delete", new { id = item.Id, employeeId = item.EmployeeId }, new { @class = "icon-button delete-icon" })
        </td>
        <td>
            @item.TaskInterval
        </td>
        <td>
            @item.ClientId
        </td>
        <td>
            @item.Info
        </td>
        <td>
            @item.Priority
        </td>
        <td>
            @String.Format("{0:g}", item.StartTime)
        </td>
        <td>
            @String.Format("{0:g}", item.EndTime)
        </td>
    </tr>
}
</tbody>
</table>
}

